# -*- coding: utf-8 -*-
import threading

__author__ = 'hftec'

from Queue import Queue
import socket
import tcp_thread




class TcpServer:
    def __init__(self):
        self.address = ('', 9088)
        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # s = socket.socket()
        self.s.bind(self.address)
        self.s.listen(5)
        threading.Thread(target=self.wait_data).start()
    def wait_data(self):
        print "tcp server start\r\n"
        try:
            while(True):
                ss, addr = self.s.accept()
                print 'got connected from',addr
                #ss.send('byebye')
                thread =  tcp_thread.TcpThread(ss)
        except KeyboardInterrupt:
            self.close()
    def close(self):
        self.s.close()